/*
 * File: exercise12.cpp
 * -------------------
 * compute PI
 * compile command :
 * g++ -Wall -g exercise12.cpp -o exercise12 -lStanfordCPPLib -I ../include/
 */

#include <iostream>
#include <cmath>
using namespace std;

const int TIMES = 10000;

int main()
{
	double P = 0;
	double h = 0;
	for(int x = 1; x <= TIMES; x++)
	{
		h = sqrt(4.0 - pow(2*(double)x/TIMES, 2));
		P += h * 2 / TIMES;
	}
	cout<<"PI = " <<P<<endl;
	return 0;
}
